#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<unistd.h>

int isFile(const char *ct){
 int test=0;
 test=open(ct,O_RDONLY) ;
 if(test==-1)
 return 1;
 else
 return 0;
 close(test);
}

int main( int nb , char ** args){

 if(nb<3)
 exit(1);
 int nbs=(int)(atoi(args[1])); //atoi 문자열을 숫자로 바꾸는 것


  int i=2;
  while(i<nb)
  {

    if(isFile(args[i])==0){
    chmod(args[i],nbs);
    if(chmod(args[i],nbs)==0)
      printf("success\n");
    else
      printf("failed\n");
    }
    else 
    exit(1);



    i++;
  }

return 0;

}
